Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Switch to CKEditor #394

Merged
merged 37 commits into from
Nov 21, 2017
Merged

Switch to CKEditor #394

merged 37 commits into from
Nov 21, 2017

Conversation

vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Nov 16, 2017

TODO

cedricium and others added 6 commits November 2, 2017 11:34
This commit sets up the classic ckeditor to be used in place of quill.
Most functionality (specifically with the footer buttons and syncing)
do not work as of yet.
The two footer buttons: `enable-sync` and `give-feedback` now work as
intended. When `enable-sync` is clicked however, the `sync-note` covers
the footer buttons currently instead of being displayed above them.
Formats added:
 - All text sizes
 - block quotes

Also added the `cursor: text` to the text editor area.
This was an attempt to build the Classic editor from source as outlined
in this guide: https://docs.ckeditor.com/ckeditor5/latest/builds/guide-
s/integration/advanced-setup.html.

This isn't bundled correctly however since ClassicEditor.js and
Markdown.js are at the top-level of the directory and need to be inside
the `sidebar/` directory.
@vladikoff vladikoff mentioned this pull request Nov 16, 2017
@vladikoff
Copy link
Contributor Author

vladikoff commented Nov 16, 2017

Hello @szymonkups and @Reinmar

This part is going mostly well but could use your advice on the following:

  • change text direction button + RTL support, do we need to write a plugin?
  • theming the editor for a dark theme (I think we can do it by just CSSing), but would like to hear your thoughts
  • do we need to write a plugin for strikethrough?

});
}
});
// content.forEach(node => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szymonkups, @Reinmar Need a bit of help here. We used to look at node attributes in Quill to detect of features are being used. How do we detect if bold, italic, etc are used? getData just returns text. In Quill there is quill.getContents(); vs quill.getData();

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be something like:

import Range from '@ckeditor/ckeditor5-engine/src/model/range';

const range = Range.createIn( editor.document.getRoot() );

for ( const value of range ) {
    if ( value.item.is( 'text' ) ) {
        console.log( Array.from( value.item.getAttributes() ) );
    } 
}

Iterating over a range uses a tree walker and value is an instance of TreeWalkerValue.

This will print which text attributes are used. You can also check which elements are used by console.log( value.item.name ) if value.item.is( 'element' ) is true.

Of course, this means that you need to build this code together with CKEditor. So you can't use a built version of CKEditor, but build CKEditor from source together with the code which uses it. It's explained here: https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/framework/guides/quick-start.html.

We're now working on making it simpler to write some basic features without building CKEditor. This means exposing more APIs somewhere in the editor properties.

PS. Why do you need to check which features are used in the editor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS. Why do you need to check which features are used in the editor?

So we can learn which features are the most popular. User research, etc.. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Natim wanna take a look at this?

need to uncomment the content.forEach(node => { function, otherwise metrics works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"uncomment" => make it work. You might need to add a dependency that includes the Range module.

build CKEditor from source together with the code which uses it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Natim Our build script is here: https://github.com/mozilla/notes/pull/394/files#diff-bef1bc0d0ce8255123c3de896c5a796b , builds and copies with npm run postinstall

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seems to work:

ERROR in ./src/ckeditor.js
Module not found: Error: Can't resolve '@ckeditor/ckeditor5-editor-classic/src/classiceditor' in '/home/rhubscher/mozilla/notes/ckeditor-build/src'
 @ ./src/ckeditor.js 6:0-85

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to install npm install --save @ckeditor/ckeditor5-editor-classic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm install --save @ckeditor/ckeditor5-build-classic nailed it.

@Reinmar
Copy link

Reinmar commented Nov 16, 2017

Great to see that you're moving forward with this :) I really want to see the final result.

  1. The bidi feature (similar to CKEditor 4's bidi plugin) is something that you'd need to implement. I guess that we'll implement it one day ourselves, but it's not on our roadmap yet. We could help you to start it. And as for UI's support for RTL, this is something that you could do yourself too, especially that I see that you're hacking the theme anyway :). RTLed UI is on our roadmap, but I don't know when we'll work on it.
  2. See https://docs.ckeditor.com/ckeditor5/latest/framework/guides/ui/theme-customization.html. But if you can wait one month, then it'd be better because we're now switching to PostCSS which will make it easier. You can read more here: 🏁 Release: CKEditor 5 v1.0.0 second alpha ckeditor/ckeditor5-design#182 in the "UI improvements" section.
  3. Yep, you'd need to write it, but it will be very simple. Just look at examples in https://github.com/ckeditor/ckeditor5-basic-styles/tree/master/src.

@vladikoff
Copy link
Contributor Author

Migration:

  • render quill hidden if you have notes in storage.
  • quill.container.firstChild.innerHTML get the html
  • call setData with html. Delete the notes storage key
  • use notesMarkdown for the new notes storage key
  • add metrics event for migration
  • only load quill if we have to do a migration
    ( * backup to localstorage and use that for backup maybe)

@vladikoff
Copy link
Contributor Author

@Reinmar thank you so much for the quick response. It is really helpful!

@cedricium I pushed fixes to the dark theme, it's ~70% there. Let me know if you have time to tweak the styles-dark.css. I won't be making changes to it for now.

@cedricium
Copy link
Collaborator

@vladikoff sure thing, will work on the dark theme 👍

@cedricium
Copy link
Collaborator

cedricium commented Nov 17, 2017

@vladikoff so far I have a fix for the 'Choose heading' label overflow and I made the link color more visible for the Dark theme. Is there anything else you saw that needs specific fixing?

cedricium and others added 3 commits November 17, 2017 21:08
Changes made result in the following:

 - fixed the heading dropdown border overlap issue

 - replicated `:hover` and `:active` styles from the light theme

 - added a border to tooltips to make them stand out better
@Natim
Copy link
Collaborator

Natim commented Nov 20, 2017

Early Beta to start QA: addon-1.9.0b1.zip

@vladikoff
Copy link
Contributor Author

@cedricium awesome work on the dark theme 👍

@vladikoff
Copy link
Contributor Author

@Natim this should be ready for release. Could you go over the code and see if you can see anything we should adjust?

One final thing to check is the metrics. Let me know if you got time to check that before merging.

I couldn't get these to work:

but I think we can ship without that. I removed the strike shortcut for now. Hopefully does not block us

@vladikoff
Copy link
Contributor Author

@cedricium feel free to also take a look ^

@cedricium
Copy link
Collaborator

cedricium commented Nov 21, 2017

-- Disregard, got it working. --

@vladikoff
Copy link
Contributor Author

-- Disregard, got it working. --

Awesome :)

@Natim
Copy link
Collaborator

Natim commented Nov 21, 2017

addon-1.9.0b2.zip

@@ -10,7 +10,7 @@ const analytics = new TestPilotGA({
ds: 'addon',
an: 'Notes Experiment',
aid: 'notes@mozilla.com',
av: '1.9.0dev' // XXX: Change version on release
av: browser.runtime.getManifest().version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Natim
Copy link
Collaborator

Natim commented Nov 21, 2017

I am going to land this to give more time to translators to catch up before next week release.

@Natim Natim merged commit d3a0b7e into master Nov 21, 2017
@vladikoff
Copy link
Contributor Author

@szymonkups and @Reinmar,

this is now live: https://medium.com/firefox-test-pilot/testpilot-notes-v1-9-0-b166c6cd7353
Thanks so much for your help!!

@Natim Natim deleted the ckeditor-concept branch February 15, 2018 09:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants